﻿using Easy.RepositoryPattern;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using ZKEACMS.Demo.Models;
using Easy;

namespace ZKEACMS.Demo.Service
{
    public class DemoService : ServiceBase<Models.TestEntity>, IDemoService
    {
        public DemoService(IApplicationContext applicationContext, DemoDbContext dbContext) : base(applicationContext, dbContext)
        {
        }

        public override DbSet<Models.TestEntity> CurrentDbSet => (DbContext as DemoDbContext).DemoDb;

        public IList<TestEntity> GetList(int pageIndex, int pageSize)
        {
            var pagin = new Pagination
            {
                PageIndex = pageIndex,
                PageSize = pageSize == 0 ? 20 : pageSize,
                OrderBy = "ID"
            };
            return base.Get(null, pagin);
        }
    }
}